package cn.anlaser.entity;

import javax.persistence.CascadeType;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.springframework.data.jpa.domain.support.AuditingEntityListener;

@MappedSuperclass
@EntityListeners({ AuditingEntityListener.class })
@Data
@EqualsAndHashCode(callSuper = false)
public abstract class RelatedEntity<PreFix extends CommonEntity, PostFix extends CommonEntity>
		extends CommonEntity {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3899663108788895603L;

	@ManyToOne(cascade = CascadeType.MERGE, optional = false, fetch = FetchType.EAGER)
	@JoinColumn(name = "PREFIX_ID")
	private PreFix preFix;

	@ManyToOne(cascade = CascadeType.MERGE, optional = false, fetch = FetchType.EAGER)
	@JoinColumn(name = "POSTFIX_ID")
	private PostFix postFix;

}
